/** * A table component for displaying resource subject data. * * @component TableComponents * *
@prop {Array} dataSource - The data source for the table. * @prop {Boolean} loading - Indicates
whether the table is in a loading state. * * @example *
<TableComponents :dataSource="subjectData" :loading="isLoading" />
*/
<template>
  <a-table :columns="columns" :data="dataSource" :loading="loading">
    <template #handle="{ record }">
      <a-button type="text" @click="$router.push({ name: 'subEditDetail' })">编辑</a-button>
      <a-button type="text" @click="$router.push({ name: 'subCheckDetail' })">查看</a-button>
      <a-button type="text" @click="handleDelEvent(record.id)">删除</a-button>
    </template>
  </a-table>
</template>

<script setup>
import { defineProps, toRefs } from 'vue';
import { Modal } from '@arco-design/web-vue';

// Define props
const props = defineProps({
  /**
   * The data source for the table.
   *
   * @type {Array}
   * @required
   */
  dataSource: {
    type: Array,
    required: true
  },
  /**
   * Indicates whether the table is in a loading state.
   *
   * @type {Boolean}
   * @default false
   */
  loading: {
    type: Boolean,
    default: false
  }
});

const { dataSource } = toRefs(props);

const columns = [
  {
    /**
     * The title of the column displaying the subject number.
     *
     * @type {String}
     */
    title: '主体编号',
    /**
     * The data index for the subject number column.
     *
     * @type {String}
     */
    dataIndex: 'code'
  },
  {
    /**
     * The title of the column displaying the subject name.
     *
     * @type {String}
     */
    title: '主体名称',
    /**
     * The data index for the subject name column.
     *
     * @type {String}
     */
    dataIndex: 'name'
  },
  {
    /**
     * The title of the column displaying the unified social credit code.
     *
     * @type {String}
     */
    title: '统一社会信用代码',
    /**
     * The data index for the unified social credit code column.
     *
     * @type {String}
     */
    dataIndex: 'credit_code'
  },
  {
    /**
     * The title of the column displaying the creation time.
     *
     * @type {String}
     */
    title: '创建时间',
    /**
     * The data index for the creation time column.
     *
     * @type {String}
     */
    dataIndex: 'created_time'
  },
  {
    title: '操作',
    slotName: 'handle',
    fixed: 'right',
    align: 'right',
    bodyCellClass: 'flex-right'
  }
];
const handleDelEvent = () => {
  Modal.confirm({
    title: 'Warning Notification',
    content:
      'This is a warning description which directly indicates a warning that might need attention.',
    cancelText: '取消',
    okText: '确定'
  });
};
</script>
